package com.example.alarmclock;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.content.DialogInterface.OnClickListener;
import android.widget.Button;

import androidx.annotation.Nullable;

public class SimpleddialogActivity extends Activity {
    Button cButton;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_dialog);

        cButton = this.findViewById(R.id.click_btn);
        cButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                AlertDialog.Builder mydialog = new AlertDialog.Builder(SimpleddialogActivity.this);
                mydialog.setMessage("这是提示消息！");
                mydialog.setTitle("消息提示");
                mydialog.setPositiveButton("确定", new MyListener());
                mydialog.setNegativeButton("取消", new MyListener2());
                mydialog.show();
            }
        });
    }

    public class MyListener implements OnClickListener {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            new AlertDialog.Builder(SimpleddialogActivity.this).setMessage("你点击了确定按钮").show();
        }
    }

    public class MyListener2 implements OnClickListener {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            new AlertDialog.Builder(SimpleddialogActivity.this).setMessage("你点击了取消").show();
        }
    }
}